package po;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

public class UserPO implements Serializable{
	private static final long serialVersionUID = 1L;

	protected String account;
	protected String password;
	protected String email;
	protected String name;
	protected String registerTime;
	protected UserStatus status = UserStatus.CUSTOMER;
	private static final String DEFAULT_PASSWORD = "123456";
	
	public UserPO(String account, String password, String name, String email) {
		this(account, password, name, email, UserStatus.GENERAL_MANAGER);
	}
	
	public UserPO(String account, String password, String name, String email, UserStatus status) {
		this.account = account;
		this.password = password;
		this.name = name;
		this.email = email;
		this.status = status;
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		registerTime = df.format(new Date());
		if(password.equals(""))
			this.password = DEFAULT_PASSWORD;
	}
	
	public String getRegisterTime() {
		return registerTime;
	}
	
	public void setStatus(UserStatus status) {
		this.status = status;
	}
	public UserStatus getStatus() {
		return status;
	}
	
	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}
	
	public String getEmail() { 
		return email;
	}
	
	public void setEmail(String email) {
		this.email = email;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setPassword(String newPassword) { 
		this.password = newPassword;
	}
	
	public void setPassword(String oldPassword, String newPassword) { 
		if(password.equals(oldPassword))
			this.password = newPassword;
	}
	
	public String getPassword() {
		return password;
	}
}
